package com.ruoyi.project.basic.carinfo.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.basic.carinfo.domain.JcCheliangda;
import com.ruoyi.project.basic.carinfo.service.IJcCheliangdaService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 车辆档案Controller
 * 
 * @author frank
 * @date 2024-08-24
 */
@RestController
@RequestMapping("/basic/carinfo/cheliangda")
public class JcCheliangdaController extends BaseController
{
    @Autowired
    private IJcCheliangdaService jcCheliangdaService;

    /**
     * 查询车辆档案列表
     */
    @PreAuthorize("@ss.hasPermi('basic/carinfo:cheliangda:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcCheliangda jcCheliangda)
    {
        startPage();
        List<JcCheliangda> list = jcCheliangdaService.selectJcCheliangdaList(jcCheliangda);
        return getDataTable(list);
    }

    /**
     * 导出车辆档案列表
     */
    @PreAuthorize("@ss.hasPermi('basic/carinfo:cheliangda:export')")
    @Log(title = "车辆档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcCheliangda jcCheliangda)
    {
        List<JcCheliangda> list = jcCheliangdaService.selectJcCheliangdaList(jcCheliangda);
        ExcelUtil<JcCheliangda> util = new ExcelUtil<JcCheliangda>(JcCheliangda.class);
        util.exportExcel(response, list, "车辆档案数据");
    }

    /**
     * 获取车辆档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic/carinfo:cheliangda:query')")
    @GetMapping(value = "/{jcCheliangdaoid}")
    public AjaxResult getInfo(@PathVariable("jcCheliangdaoid") String jcCheliangdaoid)
    {
        return success(jcCheliangdaService.selectJcCheliangdaByJcCheliangdaoid(jcCheliangdaoid));
    }

    /**
     * 新增车辆档案
     */
    @PreAuthorize("@ss.hasPermi('basic/carinfo:cheliangda:add')")
    @Log(title = "车辆档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcCheliangda jcCheliangda)
    {
        return toAjax(jcCheliangdaService.insertJcCheliangda(jcCheliangda));
    }

    /**
     * 修改车辆档案
     */
    @PreAuthorize("@ss.hasPermi('basic/carinfo:cheliangda:edit')")
    @Log(title = "车辆档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcCheliangda jcCheliangda)
    {
        return toAjax(jcCheliangdaService.updateJcCheliangda(jcCheliangda));
    }

    /**
     * 删除车辆档案
     */
    @PreAuthorize("@ss.hasPermi('basic/carinfo:cheliangda:remove')")
    @Log(title = "车辆档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jcCheliangdaoids}")
    public AjaxResult remove(@PathVariable String[] jcCheliangdaoids)
    {
        return toAjax(jcCheliangdaService.deleteJcCheliangdaByJcCheliangdaoids(jcCheliangdaoids));
    }
}
